package com.cinsea.ext.cjspx;

import com.cinsea.common.ActionType;
import com.cinsea.common.BasePX;
import com.cinsea.common.Env;
import com.cinsea.common.JdbcDao;
import com.cinsea.util.StringUtil;
import com.cinsea.workflow.model.Wfnode;

import java.util.List;
import java.util.Map;


public class FeedbackPX extends BasePX {
    @Override
    public void after(Map context) {
        JdbcDao jdbcDao = Env.getBean("jdbcDao");
        String actiontype = StringUtil.null2String(context.get("actiontype"));
        String processid = (String) context.get("processid");
        if (actiontype.equals(ActionType.ADD_FORMPROCESS) || actiontype.equals(ActionType.EDIT_FORMPROCESS)) {//回复后更新内部协调表
            String sql = "select gtname,dates,time from ut_feedback where processid=?";
            List<Map> feedbacklist = jdbcDao.queryForList(sql, new Object[]{processid});
            if (feedbacklist.size() > 0) {
                Map<String, String> feedback = feedbacklist.get(0);
                String gtname = feedback.get("gtname");
                String dates = feedback.get("dates");
                String time = feedback.get("time");
                String updatesql = "update ut_communicateinfo set endreplydate=?,endreplytime=? where processid=?";
                jdbcDao.update(updatesql, new Object[]{dates, time, gtname});
            }
        }
    }
}
